function adv_BiaoTi(JiaoBen)
{
	var str="";
	JiaoBen=JiaoBen.replace(/UName/g,$GLOBAL_USERNAME);
	if(JiaoBen.indexOf("title:")==-1)return "";
	var i=JiaoBen.indexOf("title:")+6;
	while(JiaoBen[i]!="\n")
	{
		str+=JiaoBen[i];
		i++;
	}
	return str;
}
function adv_DuiBai(JiaoBen)
{
	JiaoBen=JiaoBen.replace(/UName/g,$GLOBAL_USERNAME);
	var str="";
	var pos=0;
	var data=[];
	var flag=false;
	while(pos<JiaoBen.length)
	{
		if(JiaoBen[pos]==='(')
		{
			flag=true;
		}
		else
		if(JiaoBen[pos]===')')
		{
			
			break;
		}
		else
		{
			if(JiaoBen[pos]==="#")
			{
				while(JiaoBen[pos]!='\n'&&pos<JiaoBen.length)
				{
					pos++;
				}
				
			}
			else
			{
				if(flag&&JiaoBen[pos]!="\r")str+=JiaoBen[pos];
				
			}
		}
		pos++;
	}
	if(pos>=JiaoBen.length)
	{
		
		return [];
	}
	else
	{
		var t=str.split("\n");
		var j=-1;
		t.pop();
		for(var i=0;i<t.length;i++)
		{
			j++;
			var p=t[i].split(" ");
			var tmp="";
			if(p.length==1)
			{
				if(p[0]!="")data.push({character:p[0],dialogue:" "});
				
			}
			else{
			for(var h=1;h<p.length;h++)
			{
				tmp+=p[h]+" ";
			}
			
			data.push({character:p[0],dialogue:tmp});
			}
		}
		// for(var i=0;i<t.length;i++)
		// {
			// j++;
			// var p=t[i].split(" ");
			// for(var h=1;h<p.length;h++)
			// {
				// dig+=p[h]+" ";
			// }
			// if(p[0]!=='')data.push({character:p[0],dialogue:dig})
		// }
		return data;
	}
}
function adv_XuanZe(JiaoBen)
{
	JiaoBen=JiaoBen.replace("UName",$GLOBAL_USERNAME);
	var str="";
	var pos=0;
	var flag=false;
	while(pos<JiaoBen.length)
	{
	if(JiaoBen[pos]==='{')
	{
		flag=true;
	}
	else
	if(JiaoBen[pos]==='}')
		{
			
			break;
		}
		else
		{
			if(JiaoBen[pos]==="#")
			{
				while(JiaoBen[pos]!='\n'&&pos<JiaoBen.length)
				{
					pos++;
				}
				
			}
			else
			{
				if(flag&&JiaoBen[pos]!="\r")
				{
					str+=JiaoBen[pos];
				}
			}
		}
		pos++;
	}
	if(pos>=JiaoBen.length)
	{
		
		return [];
	}
	else
	{
		var t=str.split("\n");
		var data=[];
		t.pop();
		for(var i=0;i<t.length;i++)
		{
			var p=t[i].split(" ",2);
			if(p[0]!=='')data.push({selection:p[0],script:p[1]})
		}
		return data;
	}
}
function adv_JiaoBen(JiaoBen)
{
	JiaoBen=JiaoBen.replace(/UName/g,$GLOBAL_USERNAME);
	var str="";
	var pos=0;
	var flag=false;
	while(pos<JiaoBen.length)
	{
		if(JiaoBen[pos]==='[')
		{
			flag=true;
		}
		else
		if(JiaoBen[pos]===']')
		{
			break;
		}
		else
		{
			if(JiaoBen[pos]==="#")
			{
				while(JiaoBen[pos]!='\n'&&pos<JiaoBen.length)
				{
					pos++;
				}
			}
			else
			{
				if(flag&&JiaoBen[pos]!="\r")str+=JiaoBen[pos];
			}
		}
		pos++;
	}
	if(pos>=JiaoBen.length)
	{
		return "";
	}
	else
	{
		return str;
	}
}
function adv_MoRenZhi(obj,defaultValue)
{
	if("undefined"==typeof(obj)) 
		return defaultValue;
	else
		return obj

}
function adv_ShengChengFenQu(JiaoBen)
{
	//JiaoBen=JiaoBen.replace("UName",$GLOBAL_USERNAME);
	var str="";
	var pos=0;
	var flag=false;
	while(pos<JiaoBen.length)
	{
	if(JiaoBen[pos]==='='&&JiaoBen[pos+1]==='|')
	{
		pos++;
		flag=true;
	}
	else
	if(JiaoBen[pos]==='|'&&JiaoBen[pos+1]==="=")
		{
			
			break;
		}
		else
		{
			if(JiaoBen[pos]==="#")
			{
				while(JiaoBen[pos]!='\n'&&pos<JiaoBen.length)
				{
					pos++;
				}
				
			}
			else
			{
				if(flag&&JiaoBen[pos]!="\r")
				{
					str+=JiaoBen[pos];
				}
			}
		}
		pos++;
	}
	if(pos>=JiaoBen.length)
	{
		
		return [];
	}
	else
	{
		var t=str.split("\n");
		for(var i=0;i<t.length;i++)
		{
			if(t[i]!="")
			document.body.innerHTML+="<div id=\""+t[i]+"\" class=\"area-generate\"></div>"
		}
	}
}